/**
 * 与服务器交互文件
 */
$(document).ready(function(){
	$(".loading").css("top",$(window).height() / 2 - 30);
	
	/**
	 * 登陆事件
	 */
	$("#login").click(function(){
		var username = $("#username").val();
		var password = $("#password").val();
		var vCode = $("#vCode").val();
		if(username.length==0||password.length==0){
			//处理
			return true;
		}
		else{
			displayLoading();
			$.post("/login", { username: username, password: password ,vCode:vCode},
			function(data){
				if(data.status==1){//登陆成功
					window.location.href="/manage/index.html"; 
				}
				else{
					alert(data.msg);
					refreshValidateCode();
				}
				hiddenLoading();
			});
			return false;
		}
	});
});
function displayLoading(){
	$(".layer").css("display","block");
	$(".loading").css("display","block");
}
function hiddenLoading(){
	$(".layer").css("display","none");
	$(".loading").css("display","none");
}
function refreshValidateCode(){
	$("#validateImage").attr("src","/getVerifyCode?"+Math.random());
}